<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>3动态class</title>
    <script src="js/vue.js"></script>
    <style>
        .aClass{
            color: blue;
        }
        .bClass{
            color: red;
        }

    </style>
</head>
<body>
    <div id="demo">
        <div :class="a">文字</div>
        <div :class="{aClass: isA, bClass: isB}">文字</div>
        <button @click="changeClass()">改变</button>
    </div>
    <script>
        new Vue({
            el: '#demo',
            data:{
                a: 'aClass',
                isA: true,
                isB: false
            },
            methods:{
                changeClass(){
                    this.a = 'bClass';
                    this.isA = false;
                    this.isB = true;
                }
            }
        });
    </script>
</body>
</html>